JBoss Community Archive (Read Only)

Infinispan 5.1

Infinispan as Hibernate 2nd-Level Cache in JBoss AS 5.x

A JBoss AS 5.x application can be configured to use Infinispan 4.x as the Hibernate 2nd-level cache, replacing JBoss Cache.

  1. Add the attached jar files to the ear lib directory. These include the core 4.1.0.GA Infinispan jar (infinispan-core.jar), the Hibernate/Infinispan integration jar back-ported from Hibernate 3.5 (hibernate-infinispan-3.3.2.GA_CP03.jar), the JGroups jar required by Infinispan 4.1.0 (jgroups-2.10.0.GA.jar), and other required 3rd party jars (river-1.2.3.GA.jar, marshalling-api-1.2.3.GA.jar)

  2. Isolate the classloading to be ear-scoped by adding META-INF/jboss-classloading.xml

  3. <classloading xmlns="urn:jboss:classloading:1.0" domain="simple-scoped" parent-first="false" />
  4. Configure persistence.xml to use Infinispan instead of JBoss Cache:

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
       version="1.0">
    <persistence-unit name="jpa-test">
        <jta-data-source>java:/PostgresDS</jta-data-source>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
    
                <property name="hibernate.session_factory_name" value="SessionFactories/infinispan" />
    
                <property name="hibernate.cache.use_query_cache" value="true" />
                <property name="hibernate.cache.use_second_level_cache" value="true" />
                <property name="hibernate.generate_statistics" value="true" />
                <property name="hibernate.cache.use_structured_entries" value="true" />
    
                <property name="hibernate.cache.region_prefix" value="infinispan" />
    
                <property name="hibernate.show_sql" value="true" />
    
                <property name="hibernate.hbm2ddl.auto" value="validate" />
                
                <!-- Infinispan second level cache configuration -->
                <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
            </properties>
        </persistence-unit>
    </persistence>

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 09:16:11 UTC, last content change 2011-07-20 09:00:51 UTC.